package runnable;

class PrintRunnable implements Runnable{
    int i=1;
    @Override
    public void run() {
        while (i<=10){
            System.out.println(Thread.currentThread().getName()+"正在运行"+(i++));
        }
    }
}
public class Test {
    public static void main(String[] args) {
        //定义Runnable实现类的对象
        PrintRunnable pr1=new PrintRunnable();
        //创建线程类的对象
        Thread t1=new Thread(pr1,"线程1");
        //启动线程
        t1.start();

        //PrintRunnable pr2=new PrintRunnable();
        Thread t2=new Thread(pr1,"线程2");
        t2.start();

    }
}
